<?php

namespace Wzbmail\Yii2Api\enum;

/**
 * label Enum label methods
 * @method static labelMapping()
 */
trait LabelTrait
{
    public static function getLabels(?self ...$enums): array
    {
        $mapping = self::labelMapping();

        $enums = empty($enums) ? self::cases() : $enums;
        $labels = [];
        foreach ($enums as $enum) {
            $labels[$enum->value] = $mapping[$enum->value];
        }
        return $labels;
    }

    public function getLabel(): string
    {
        return self::labelMapping()[$this->value];
    }
}